package bat.iog.hytool.tomcat.connector;


import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;

public class TomcatSocket<S> {


    //protected SynchronizedStack<SocketProcessorBase<S>> processorCache;
    //private SynchronizedStack<PollerEvent> eventCache;
    //private SynchronizedStack<NioChannel> nioChannels;
    boolean running = true;
    boolean paused = false;
    
    private Poller poller = null;
    
    private volatile ServerSocketChannel serverSock = null;

    protected void initServerSocket() throws Exception{
        serverSock = ServerSocketChannel.open();
        //socketProperties.setProperties(serverSock.socket()); //设置socket属性
        InetSocketAddress addr = new InetSocketAddress(8080);
        serverSock.bind(addr, 1);
    }

    public void startInternal() throws Exception {
        if(!running){
            running = true;
            paused = true;

            
            
            
            
            // Start poller thread
            poller = new Poller();
            Thread pollerThread = new Thread(poller,  "Poller");
            
        }
    }

    public class Poller implements Runnable {

        private Selector selector;

        public Poller() throws IOException {
            this.selector = Selector.open();
        }

        @Override
        public void run() {
            
        }
    }
    
    
    
}
